home *** CD-ROM | disk | FTP | other *** search
/ Lexis Nexis Millenium Plus Collection 1997 to 1997 / Lexis-Nexis Millenium Plus Collection - 1996-97 (Lexis-Nexis)(LA1173-0 07-96)(1996).bin / pc / office / lnoffice / folio / disk1 / msregdb.in_ / msregdb.in
Text File  |  1995-02-27  |  3KB  |  92 lines

  1. '$DEFINE REG_DB_ENABLED
  2.  
  3. const REG_SZ               = 1
  4. const HKEY_CLASSES_ROOT    = 1
  5. const ERROR_SUCCESS        = 0
  6.  
  7.  
  8. DECLARE FUNCTION EercErrorHandler LIB "mscomstf.dll" (grc%, fVital%, sz1$, sz2$, sz3$) AS INTEGER
  9. CONST GRC_API_FAILED       = 104
  10.  
  11. DECLARE FUNCTION RegOpenKey LIB "SHELL.DLL" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  12. DECLARE FUNCTION RegCreateKey LIB "shell.dll" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  13. DECLARE FUNCTION RegDeleteKey LIB "shell.dll" (hKey&, szSubKey$) AS LONG
  14. DECLARE FUNCTION RegCloseKey LIB "shell.dll" (hKey&) AS LONG
  15. DECLARE FUNCTION RegQueryValue LIB "shell.dll" (hKey&, szSubKey$, szValue$, lpcb AS POINTER TO LONG) AS LONG
  16. DECLARE FUNCTION RegSetValue LIB "shell.dll" (hKey&, szSubKey$, dwType&, szValue$, cbValue&) AS LONG
  17. DECLARE FUNCTION RegEnumKey LIB "shell.dll" (HkEY&, dwIndex&, szBuffer$, dwBufferSize&) AS LONG
  18.  
  19.  
  20. DECLARE SUB CreateRegKey(szKey$)
  21. DECLARE SUB CreateRegKeyValue(szKey$, szValue$)
  22. DECLARE SUB SetRegKeyValue(szKey$, szValue$)
  23. DECLARE SUB DeleteRegKey(szKey$)
  24. DECLARE FUNCTION GetRegKeyValue(szKey$) AS STRING
  25. DECLARE FUNCTION DoesRegKeyExist(szKey$) AS INTEGER
  26.  
  27. SUB CreateRegKey(szKey$) STATIC
  28.     DIM phKey AS LONG
  29.  
  30.     IF RegCreateKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) > ERROR_SUCCESS THEN
  31.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  32.         ERROR STFERR
  33.     END IF
  34.  
  35.     IF RegCloseKey(phKey) > ERROR_SUCCESS THEN
  36.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  37.         ERROR STFERR
  38.     END IF
  39. END SUB
  40.  
  41. SUB CreateRegKeyValue(szKey$, szValue$) STATIC
  42.     DIM phKey AS LONG
  43.  
  44.     IF RegSetValue(HKEY_CLASSES_ROOT, szKey$, REG_SZ,  szValue$, len(szKey$)) > ERROR_SUCCESS THEN
  45.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKeyValue", NULL, NULL)
  46.         ERROR STFERR
  47.     END IF
  48. END SUB
  49.  
  50. FUNCTION DoesRegKeyExist(szKey$) STATIC AS INTEGER
  51.     DIM phKey AS LONG
  52.  
  53.     IF RegOpenKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) = ERROR_SUCCESS THEN
  54.         i = RegCloseKey(phKey)
  55.         DoesRegKeyExist = 1
  56.     ELSE
  57.         DoesRegKeyExist = 0
  58.     ENDIF
  59. END FUNCTION
  60.  
  61. SUB SetRegKeyValue(szKey$, szValue$) STATIC
  62.     DIM phKey AS LONG
  63.  
  64.     IF RegSetValue(HKEY_CLASSES_ROOT, szKey$, REG_SZ,  szValue$, len(szKey$)) > ERROR_SUCCESS THEN
  65.         i% = EercErrorHandler(GRC_API_FAILED, 1, "SetRegKeyValue", NULL, NULL)
  66.         ERROR STFERR
  67.     END IF
  68. END SUB
  69.  
  70. FUNCTION GetRegKeyValue(szKey$) STATIC AS STRING
  71.     szValue$ = string$(512,32)
  72.     cb& = len(szValue$)
  73.  
  74.     IF DoesRegKeyExist(szKey$) = 0 THEN
  75.         GetRegKeyValue = ""
  76.         EXIT FUNCTION
  77.     END IF
  78.  
  79.     IF RegQueryValue(HKEY_CLASSES_ROOT, szKey$, szValue$, VARPTR(cb)) = ERROR_SUCCESS THEN
  80.         GetRegKeyValue = MID$(szValue$, 1, cb)
  81.     ELSE
  82.         i% = EercErrorHandler(GRC_API_FAILED, 1, "SetRegKeyValue", NULL, NULL)
  83.         ERROR STFERR
  84.     END IF
  85.     szValue$ = ""
  86. END FUNCTION
  87.  
  88. SUB DeleteRegKey(szKey$) STATIC
  89.     i& = RegDeleteKey(HKEY_CLASSES_ROOT, szKey$)
  90. END SUB
  91.  
  92.